/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.easoftware.code.beans.jpa;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author waumovil-javaengineer
 */
@Entity
@Table(name = "tasa_cambio")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TasaCambio.findAll", query = "SELECT t FROM TasaCambio t"),
    @NamedQuery(name = "TasaCambio.findById", query = "SELECT t FROM TasaCambio t WHERE t.id = :id"),
    @NamedQuery(name = "TasaCambio.findByValor", query = "SELECT t FROM TasaCambio t WHERE t.valor = :valor"),
    @NamedQuery(name = "TasaCambio.findByMes", query = "SELECT t FROM TasaCambio t WHERE t.mes = :mes"),
    @NamedQuery(name = "TasaCambio.findByAnio", query = "SELECT t FROM TasaCambio t WHERE t.anio = :anio"),
    @NamedQuery(name = "TasaCambio.findUnidadNegocio", query = "SELECT t FROM TasaCambio t WHERE t.mes = :mes and t.anio = :anio and t.unidadnegocio.id = :idun")})
public class TasaCambio implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "valor")
    private double valor;
    @Basic(optional = false)
    @NotNull
    @Column(name = "mes")
    private int mes;
    @Basic(optional = false)
    @NotNull
    @Column(name = "anio")
    private int anio;
    @JoinColumn(name = "unidadnegocio", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private UnidadNegocio unidadnegocio;

    public TasaCambio() {
    }

    public TasaCambio(Integer id) {
        this.id = id;
    }

    public TasaCambio(Integer id, double valor, int mes, int anio) {
        this.id = id;
        this.valor = valor;
        this.mes = mes;
        this.anio = anio;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public double getValor() {
        return valor;
    }

    public void setValor(double valor) {
        this.valor = valor;
    }

    public int getMes() {
        return mes;
    }

    public void setMes(int mes) {
        this.mes = mes;
    }

    public int getAnio() {
        return anio;
    }

    public void setAnio(int anio) {
        this.anio = anio;
    }

    public UnidadNegocio getUnidadnegocio() {
        return unidadnegocio;
    }

    public void setUnidadnegocio(UnidadNegocio unidadnegocio) {
        this.unidadnegocio = unidadnegocio;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += ( id != null ? id.hashCode() : 0 );
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!( object instanceof TasaCambio )) {
            return false;
        }
        TasaCambio other = (TasaCambio) object;
        if (( this.id == null && other.id != null ) || ( this.id != null && !this.id.equals(other.id) )) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "net.easoftware.code.beans.jpa.TasaCambio[ id=" + id + " ]";
    }
}
